-- permit
-- created by panyl
-- 遗迹建筑功能-掠夺许可证

return {
    canDevelop = function(id)
        -- local cond = SkyRelicFunctionM.query(id, "condition");
        -- 累计获得超过统计
        if ME.user.dbase:query("rob_permit_show", 0) ~= 1 then
            return false;
        end

        -- 不超过矿工和矿车
        if SkyRelicFunctionM.getLevel(id) >= SkyRelicFunctionM.getLevel(1) then
            return false;
        end

        if SkyRelicFunctionM.getLevel(id) >= SkyRelicFunctionM.getLevel(2) then
            return false;
        end

        return true;
    end,

    -- 其它限制
    limitDevelopDesc = function(id)
        local level1 = SkyRelicFunctionM.getLevel(1);
        local level2 = SkyRelicFunctionM.getLevel(2);
        local needLevel = SkyRelicFunctionM.getLevel(id) + 1;
        local desc = "";

        if level1 < needLevel then
            desc = string.format(getLocStr("permit_limit_tip1"), needLevel, level1);
        elseif level2 < needLevel then
            desc = string.format(getLocStr("permit_limit_tip2"), needLevel, level2);
        end

        return desc;
    end,

    -- 获取描述
    getDesc = function(desc)
        -- 抢夺量
        local storeSize = FormulaM.invoke("CALC_ROB_STORE_SIZE", ME.user);
        desc = string.gsub(desc, "{0}", tostring(storeSize));
        return desc;
    end,
};
